# Contributor: Dhruvin Gandhi <contact@dhruvin.dev>
# Maintainer: Dhruvin Gandhi <contact@dhruvin.dev>
pkgname=hledger-ui
pkgver=1.26
pkgrel=0
pkgdesc="Curses-style terminal interface for the hledger accounting system"
url="https://hledger.org/hledger-ui.html"
arch="x86_64" # limited by ghc
license="GPL-3.0-only"
makedepends="ghc cabal libffi-dev ncurses-dev"
subpackages="$pkgname-doc"
source="https://hackage.haskell.org/package/hledger-ui-$pkgver/hledger-ui-$pkgver.tar.gz
	cabal.project.freeze"

export CABAL_DIR="$srcdir"/cabal

prepare() {
	default_prepare
	cp "$srcdir"/cabal.project.freeze .
}

build() {
	cabal update
	cabal build --prefix=/usr --enable-relocatable
}

check() {
	cabal test
}

package() {
	local ghcver=$(ghc --version | cut -d " " -f 8)
	install -Dm755 \
		"dist-newstyle/build/$arch-linux/ghc-$ghcver/$pkgname-$pkgver/x/$pkgname/build/$pkgname/$pkgname" \
		"$pkgdir"/usr/bin/$pkgname
	install -Dm644 $pkgname.1 "$pkgdir"/usr/share/man/man1/$pkgname.1
}

sha512sums="
63c299af40f29bfe99e1af3508f43051e8e5f8ead4d90b4af51607fe333899d10b21732ba12614ef6a41e389fcf2d7662f0986acff78e6b9451d5fe67f695837  hledger-ui-1.26.tar.gz
486e49d491fc0113c9c8ef06b9d7321c82038c348f8dae3037451c27d8966d64c9dc1c01f356071a2bf00dd461b654033e896006b88107ba5318033aea477d84  cabal.project.freeze
"
